package com.king.sort;

/**
 * 冒泡排序:
 * 	for(var i=0; i<arr.length; i++) {
 * 		for(var j=i+1; j<=arr.length-1; j++) {
 * 			if(eval(arr[i]) < eval(arr[j])) {
 * 				temp = arr[i];
 * 				arr[i] = arr[j];
 * 				arr[j] = temp;
 * 			}
 * 		}
 * 	}
 */
public class BubbleSort implements SortUtil.Sort {

	public void sort(int[] data) {
		int temp;
		for (int i = 0; i < data.length; i++) {
			for (int j = data.length - 1; j > i; j--) {
				if (data[j] < data[j - 1]) {
					SortUtil.swap(data, j, j - 1);
				}
			}
		}
	}

}